package com.tianji.mq.produce;

import com.tianji.common.constant.MqConstants;
import lombok.RequiredArgsConstructor;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

import java.util.HashMap;


@Service
@RequiredArgsConstructor
public class CouponProducer {


    private final RocketMQTemplate rocketMQTemplate;


    public void sendCouponUpdateMessage(Long userId,Long couponId) {
        HashMap<String, String> map = new HashMap<>();
        map.put("couponId", couponId.toString());
        map.put("userId", userId.toString());
        rocketMQTemplate.send(MqConstants.EXCHANGE+":"+MqConstants.ROUTING_KEY, MessageBuilder.withPayload(map).build());
    }
}
